package na.learn.java.corepatterns.caching;

import java.util.LinkedList;

import na.learn.java.Logging.CacheLogger;

import org.apache.log4j.Logger;

public class FIFOQueue extends LinkedList {
	private String name;

	private int maxAllocSize;

	private int threashold;

	private static Logger logger;

	static {
		logger = CacheLogger.getLogger(FIFOQueue.class.getName());
	}

	public FIFOQueue() {
		super();
		logger.info("FIFO Queue Created by: " + Thread.currentThread());
	}

	public int getMaxAllocSize() {
		return maxAllocSize;
	}

	public void setMaxAllocSize(int maxAllocSize) {
		this.maxAllocSize = maxAllocSize;
	}

	public int getThreashold() {
		return threashold;
	}

	public void setThreashold(int threashold) {
		this.threashold = threashold;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Object remove() {
		return super.remove();

	}
	
	
	public boolean hasVacancy() {
		synchronized (this) {
			if (size() < maxAllocSize)
				return true;
			else
				return false;
		}
	}

}